package com.qianfeng.front.biz.impl;

import com.qianfeng.front.biz.IOrderBiz;
import com.qianfeng.ls.entity.OrderEntity;
import com.qianfeng.ls.mapper.OrderMapper;
import com.qianfeng.ls.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrderBizImpl implements IOrderBiz {

    @Autowired
    OrderMapper orderMapper;

    @Override
    public OrderEntity createOrder(String[] gids, int aid) {

        //1: 创建订单; 往订单表里面添加一条纪录
        OrderEntity oe = new OrderEntity();
        oe.setOid(StringUtil.getUUID());
        oe.setAid(aid);
        oe.setAddressId(1);
        oe.setOtotalPrice(200);
        boolean flag = orderMapper.addOrder(oe);

        //2: 创建订单详情; 往订单表里面添加多条纪录
        boolean result = false;
        if (flag) {
            result = orderMapper.addOrderDetail(gids, oe.getOid());
        }

        return oe;
    }


    /**
     * 将我们的订单设置成失效
     * @param oid
     * @return
     */
    public boolean updStatus(String oid){
        return orderMapper.updStatus(oid);
    }

}
